'use strict'
class poem{
    constructor() {

    }
    async get(c) {
        let dy = c.param.id;
        console.log(dy)
        switch (dy) {//利用switch对不同参数进行查询
            case 'chun':
                let sqltext1 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r1 = await c.service.psql.query(sqltext1,['春秋战国时期']);
                console.log(r1.rows)
                c.send(JSON.stringify(r1.rows))
                break;
            case 'qin':
                let sqltext2 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r2 = await c.service.psql.query(sqltext2,['秦汉时期']);
                console.log(r2.rows)
                c.send(JSON.stringify(r2.rows))
                break;
            case 'wei':
                let sqltext3 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r3 = await c.service.psql.query(sqltext3,['魏晋南北朝时期']);
                console.log(r3.rows)
                c.send(JSON.stringify(r3.rows))
                break;
            case 'sui':
                let sqltext4 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r4 = await c.service.psql.query(sqltext4,['隋唐时期']);
                console.log(r4.rows)
                c.send(JSON.stringify(r4.rows))
                break;
            case 'liao':
                let sqltext5 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r5 = await c.service.psql.query(sqltext5,['宋元时期']);
                console.log(r5.rows)
                c.send(JSON.stringify(r5.rows))
                break;
            case 'ming':
                let sqltext6 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r6 = await c.service.psql.query(sqltext6,['明朝时期']);
                console.log(r6.rows)
                c.send(JSON.stringify(r6.rows))
                break;
            case 'qing':
                let sqltext7 = `SELECT * FROM poem WHERE "poemDynasty"=$1 ORDER BY "poemId" ASC`;
                let r7 = await c.service.psql.query(sqltext7,['清朝时期']);
                console.log(r7.rows)
                c.send(JSON.stringify(r7.rows))
                break;
            
        }
    }
}
module.exports = poem;